﻿
@{
    ViewBag.Title = "Edit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model YTCMS.Domain.Entities.viewcompany
<div class="row">
    <div class="col-lg-12">
        <h3 class="page-header"><i class="fa fa-laptop"></i> 宇途后台管理系统</h3>
        <ol class="breadcrumb">
            <li><i class="fa fa-home"></i><a href="/">主页</a></li>
            <li><i class="fa fa-laptop"></i><a href="/company/index">机构管理</a></li>
            <li><i class="fa fa-plus"></i>修改</li>
        </ol>
    </div>
</div>

<div class="row">
    <div class="col-xs-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h2><i class="fa fa-indent red"></i><strong>机构用户基本信息</strong></h2>
            </div>
            <div class="panel-body">
                <form action="" method="post" id="form1" name="form1" enctype="multipart/form-data" class="form-horizontal ">
                    @Html.ValidationSummary(true)
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="text-input">机构名称</label>
                        <div class="col-md-9">
                            @Html.TextBoxFor(s => s.UserName, new { @class = "form-control", @placeholder = "机构名称" })
                            @Html.ValidationMessageFor(s => s.UserName)
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="text-input">机构代码</label>
                        <div class="col-md-9">
                            @Html.TextBoxFor(s => s.Code, new { @class = "form-control", @placeholder = "机构代码" })
                            @Html.ValidationMessageFor(s => s.Code)
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="password-input">机构邮箱</label>
                        <div class="col-md-9">
                            @Html.TextBoxFor(s => s.Email, new { @class = "form-control", @placeholder = "机构邮箱" })
                            @Html.ValidationMessageFor(s => s.Email)
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="password-input">联系电话</label>
                        <div class="col-md-9">
                            @Html.TextBoxFor(s => s.Mobile, new { @class = "form-control", @placeholder = "联系电话" })
                            @Html.ValidationMessageFor(s => s.Mobile)
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-3 control-label" for="password-input">联系QQ</label>
                        <div class="col-md-9">
                            @Html.TextBoxFor(s => s.QQ, new { @class = "form-control", @placeholder = "联系QQ" })
                            @Html.ValidationMessageFor(s => s.QQ)
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="password-input">营业执照</label>
                        <div class="col-md-9">
                            @Html.TextBoxFor(s => s.License, new { @class = "form-control", @placeholder = "营业执照" })
                            @Html.ValidationMessageFor(s => s.License)
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="password-input">机构联系人</label>
                        <div class="col-md-9">
                            @Html.TextBoxFor(s => s.Contacts, new { @class = "form-control", @placeholder = "机构联系人" })
                            @Html.ValidationMessageFor(s => s.Contacts)
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="password-input">机构法人</label>
                        <div class="col-md-9">
                            @Html.TextBoxFor(s => s.Legal, new { @class = "form-control", @placeholder = "机构法人" })
                            @Html.ValidationMessageFor(s => s.Legal)
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="password-input">法人证件号</label>
                        <div class="col-md-9">
                            @Html.TextBoxFor(s => s.Identitycard, new { @class = "form-control", @placeholder = "法人证件号" })
                            @Html.ValidationMessageFor(s => s.Identitycard)
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="password-input">金额</label>
                        <div class="col-md-9">
                            @Html.TextBoxFor(s => s.Money, new { @class = "form-control", @placeholder = "法人证件号" })
                            @Html.ValidationMessageFor(s => s.Money)
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="password-input">机构地址</label>
                        <div class="col-md-9">
                            @Html.TextBoxFor(s => s.Address, new { @class = "form-control", @placeholder = "机构地址" })
                            @Html.ValidationMessageFor(s => s.Address)
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="password-input">机构经营项目</label>
                        <div class="col-md-9">
                            @Html.TextBoxFor(s => s.Project, new { @class = "form-control", @placeholder = "机构经营项目" })
                            @Html.ValidationMessageFor(s => s.Project)
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="password-input">机构网站地址</label>
                        <div class="col-md-9">
                            @Html.TextBoxFor(s => s.WebSite, new { @class = "form-control", @placeholder = "机构网站地址" })
                            @Html.ValidationMessageFor(s => s.WebSite)
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="password-input">状态</label>
                        <div class="col-md-9">
                            @Html.DropDownListFor(s => s.State, Admin.Common.YTDDL.CommonState(true, Model.State.ToString()), new { @class = "form-control" })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="password-input">企业Logo</label>
                        <div class="col-md-9">
                            <input type="file" id="file_upload" name="file_upload">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> </label>
                        <div class="col-sm-9" id="divimg">
                            <img src="@Model.Image" height="100px" width="80px" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="password-input">机构简介</label>
                        <div class="col-md-9">
                            @Html.TextAreaFor(s => s.Remark, new { @class = "form-control", @placeholder = "机构简介" })

                        </div>
                    </div>
                    <br>
                    @Html.Hidden("hidimage",Model.Image)
                    @Html.HiddenFor(s => s.Id)
                    @Html.HiddenFor(s => s.Pwd)
                    @Html.HiddenFor(s => s.EncryptContent)
                    @Html.HiddenFor(s => s.CreateTime)
                    @Html.HiddenFor(s => s.RegistIP)
                    @Html.HiddenFor(s => s.OnlineStatus)
                    @Html.HiddenFor(s => s.UserType)
                </form>
            </div>
            <div class="panel-footer">
                <button type="button" class="btn btn-sm btn-success" id="btn_Save1"><i class="fa fa-dot-circle-o"></i> 保存</button>
                <button type="reset" class="btn btn-sm btn-danger" onclick="javascript:document.form1.reset();"><i class="fa fa-ban"></i> 重置</button>
            </div>
        </div>
    </div>

</div>

<script>
    $(function () {
        $("#btn_Save1").click(function () {
            if ($("#form1").valid()) {
                $.post("/company/edit", $("#form1").serialize(), function (result) {
                    if (result.d) {
                        jAlert("修改成功", "提示", function () {
                            window.location.href = "/company/index";
                        });
                    }
                    else {
                        jAlert(result.msg, "提示");
                    }
                })
            }
        });
    })
    setTimeout(function () {
        jQuery('#file_upload').uploadify({
            'swf': '/Scripts/uploadify.swf',
            'uploader': '/Util/ImgUpload',
            'fileTypeExts': '*.gif; *.jpg; *.png; *.bmp; *.jpeg',
            'multi': false,
            'fileObjName': 'filedata',
            'wmode': 'transparent',
            'fileSizeLimit': '2MB',
            'onSelectError': function (file, errorCode, errorMsg) {
                jAlert("文件大小超出系统限制的", "提示")
            },
            'onFallback': function () {
                jAlert("您未安装FLASH控件，无法上传图片！请安装FLASH控件后再试。", "提示");
            },
            onUploadSuccess: function (file, data, respone) {
                $("#divimg").empty().append("<div class='expdiv'><div class='expbtn'><a href='javascript:void(0)' onclick='imgclose(this)' value='" + data + "'></a></div><img src='" + data + "' height='100px' width='80px' /></div>")
                $("#hidimage").val(data)
            }
        });
    }, 10);
</script>
